package com.googlecode.grima.domain;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "PORTAL_DESCRIPTIVE")
public class Descriptive extends com.googlecode.grima.base.Entity {

	private static final long serialVersionUID = 51224217935000036L;

	private String status;
	private Partner customer;
	private String comments;
	private String processInstanceId;
	private List<DescriptiveItem> items;
	private List<DescriptiveItem> deleteItems;
	private String collection;
	private String segment;
	

	@Column(name = "STATUS")
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Column(name = "PROCESS_INSTANCE_ID")
	public String getProcessInstanceId() {
		return processInstanceId;
	}

	public void setProcessInstanceId(String processInstanceId) {
		this.processInstanceId = processInstanceId;
	}

	@Column(name = "COLLECTION")
	public String getCollection() {
		return collection;
	}

	public void setCollection(String collection) {
		this.collection = collection;
	}

	@Column(name = "SEGMENT")
	public String getSegment() {
		return segment;
	}

	public void setSegment(String segment) {
		this.segment = segment;
	}

	@OneToMany(targetEntity = DescriptiveItem.class, mappedBy = "descriptive", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
	public List<DescriptiveItem> getItems() {
		if (items == null) {
			items = new ArrayList<DescriptiveItem>();
		}
		return items;
	}

	public void setItems(List<DescriptiveItem> items) {
		this.items = items;
	}

	@Column(name = "COMMENTS")
	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

	@ManyToOne
	@JoinColumn(name = "CUSTOMER_ID")
	public Partner getCustomer() {
		return customer;
	}

	public void setCustomer(Partner customer) {
		this.customer = customer;
	}

	@Transient
	public List<DescriptiveItem> getDeleteItems() {
		return deleteItems;
	}

	public void setDeleteItems(List<DescriptiveItem> deleteItems) {
		this.deleteItems = deleteItems;
	}

}